package com.example.malltest0.service.impl;

import com.example.malltest0.common.utils.RequestUtil;
import com.example.malltest0.dao.FollowBlogDao;
import com.example.malltest0.mbg.mapper.BlogsMapper;
import com.example.malltest0.mbg.mapper.FollowBlogMapper;
import com.example.malltest0.mbg.model.Blogs;
import com.example.malltest0.mbg.model.FollowBlog;
import com.example.malltest0.mbg.model.Followers;
import com.example.malltest0.service.BlogService;
import com.example.malltest0.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService {

    @Autowired
    private BlogsMapper blogsMapper;

    @Autowired
    private FollowBlogMapper followBlogMapper;

    @Autowired
    private FollowBlogDao followBlogDao;

    @Autowired
    private FollowService followService;

    @Override
    public void insertBlog(Blogs blogs, Long fid) {
        blogsMapper.insert(blogs);
        FollowBlog followBlog=new FollowBlog();
        followBlog.setBid(blogs.getId());
        followBlog.setFid(fid);
        followBlogMapper.insert(followBlog);
    }

    @Override
    public Blogs selectOne(Long bid) {
        return blogsMapper.selectByPrimaryKey(bid);
    }

    @Override
    public List<Followers> selectByFid(Long fid) {

        return followBlogDao.selectByFid(fid);
    }

    @Override
    public List<Blogs> getBlogByFid(Long fid) {
        String s = RequestUtil.httpRequest(followService.selectById(fid).getLink());

        return null;
    }
}
